package com.fc.mall.decoration.page.model;


import com.fc.mall.decoration.page.object.PageStatus;
import com.fc.mall.decoration.page.object.PageType;
import com.fc.mall.decoration.widget.object.PageWidget;
import com.fc.mall.mongo.model.VersionedObject;
import com.fc.mall.util.Utils;
import lombok.Getter;
import lombok.Setter;
import org.joda.time.DateTime;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.List;

@Getter
@Setter
@Document(collection = "custompages")
public class CustomPage extends VersionedObject {
    @Id
    private String id;

    @Indexed
    private String name;

    private PageType pageType;

    private String description;

    private PageStatus status;

    private DateTime activeTime;

    private DateTime expireTime;

    private Boolean isDefault;

    private List<PageWidget> pageWidgets;

    public static CustomPage createNew() {
        CustomPage customPage = new CustomPage();
        customPage.setId(Utils.generateId());
        return customPage;
    }
}
